package de.saumya.webfortune.client;


public class Quote {

  final Topic topic;
  
  private int id;
    
  public Quote(Topic topic){
    this.topic = topic;
  }
  
  public String file(){
    return topic.name + "/" + id + ".xml";
  }
  
  public void next(){
    id++;
    if(id == topic.max){
      id = 0;
    }
  }
  
  public void previous(){
    id--;
    if(id == -1){
      id = topic.max - 1;
    }
  }
  
  public void random(){
    do {
      id = (int)(Math.random() * topic.max);
    }
    while(topic.max == id);
  }
 
}
